package com.kaiwukj.android.ufamily.utils;

import com.blankj.utilcode.util.SPUtils;

public class UserStore {

    private static final String TAG = "user";

    private static final String TAG_LOGIN = "user_login";

    private static final String LOGIN_PHONE = "loginPhone";
    private static final String HX_MANAGER_ID = "hxManagerId";
    private static final String COMMUNITY_ID = "communityId";
    private static final String COMMUNITY_NAME = "communityName";
    private static final String OWN_ID = "ownId";
    private static final String JPUSH_ALIAS = "JPushAlias";

    public static void putLoginPhone(String phone) {
        SPUtils.getInstance(TAG).put(LOGIN_PHONE, phone);
    }

    //管家ID
    public static void putHXManagerId(String hxId) {
        SPUtils.getInstance(TAG).put(HX_MANAGER_ID, hxId);
    }

    public static void putCommity(int id, String name) {
        putCommitiyId(id);
        putCommunityName(name);
    }

    public static void putCommitiyId(int id) {
        SPUtils.getInstance(TAG).put(COMMUNITY_ID, id);
    }

    //小区name
    public static void putCommunityName(String name) {
        SPUtils.getInstance(TAG).put(COMMUNITY_NAME, name);
    }

    public static void putOwnId(int id) {
        SPUtils.getInstance(TAG).put(OWN_ID, id);
    }

    public static String getLoginPhone() {
        return SPUtils.getInstance(TAG).getString(LOGIN_PHONE);
    }


    public static String getHXManagerId() {
        return SPUtils.getInstance(TAG).getString(HX_MANAGER_ID, "");
    }

    public static int getCommunityId() {
        return SPUtils.getInstance(TAG).getInt(COMMUNITY_ID, -1);
    }

    public static String getCommunityName() {
        return SPUtils.getInstance(TAG).getString(COMMUNITY_NAME, "");
    }

    public static int getOwnId() {
        return SPUtils.getInstance(TAG).getInt(OWN_ID, 0);
    }

    public static void putJPushAlias(String alias) {
        SPUtils.getInstance(TAG).put(JPUSH_ALIAS, alias);
    }

    public static String getJpushAlias() {
        return SPUtils.getInstance(TAG).getString(JPUSH_ALIAS);
    }

    public static void clearAll() {
        SPUtils.getInstance(TAG).clear();
    }

    public static void putUName(String uName) {
        putLogin(LOGIN_PHONE, uName);
    }

    public static String getUName() {
        return SPUtils.getInstance(TAG_LOGIN).getString(LOGIN_PHONE);
    }

    private static void putLogin(String key, String value) {
        SPUtils.getInstance(TAG_LOGIN).put(key, value);
    }

}
